package org.example.Server.controller.semester;


import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.semester.SemAddStu;
import org.example.Server.service.semester.SemesterService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/youxich/semester/stu")
public class SemesterStuController {
    @Autowired
    SemesterService semesterService;

    /**
     * 获取学生加入的课堂列表
     *
     * @param user_id
     * @param semester_status
     * @return
     */
    @GetMapping
    public ResultAPI getSemStuList(@RequestParam int user_id,
                                   @RequestParam(required = false, defaultValue = "0") Integer semester_status) {
        return semesterService.getSemStuList(user_id, semester_status);
    }

    /**
     * 学生加入课堂
     *
     * @param semAddStu
     * @return
     */
    @PostMapping
    public ResultAPI addSemesterStu(@RequestBody SemAddStu semAddStu) {
        return semesterService.addSemesterStu(semAddStu);
    }

    /**
     * 获取学生课堂详情
     *
     * @param stu_id
     * @param semester_id
     * @return
     */
    @GetMapping("/detail")
    public ResultAPI getStuSem(@RequestParam Integer stu_id, @RequestParam Integer semester_id) {
        return semesterService.getSemStuDetail(stu_id, semester_id);
    }

    /**
     * 获取学生课堂数据
     *
     * @param stu_id
     * @param semester_id
     * @return
     */
    @GetMapping("/data")
    public ResultAPI getStuData(@RequestParam Integer stu_id, @RequestParam Integer semester_id) {
        return semesterService.getStuData(stu_id, semester_id);
    }

    @DeleteMapping("{stu_semester_id}")
    public ResultAPI deleteStuSem(@PathVariable Integer stu_semester_id) {
        return semesterService.deleteStuSem(stu_semester_id);
    }
}
